package work;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Problem13 {

    public List<List<Integer>> threeSum(int[] nums) {

        int i, j, k;
        List<List<Integer>> result = new ArrayList<>();
        for (i = 0; i < nums.length; i++) {
            for (j = i + 1; j < nums.length; j++) {
                for (k = j + 1; k < nums.length; k++) {
                    if (nums[i] + nums[j] + nums[k] == 0) {
                        List<Integer> numbers = new ArrayList<>();
                        numbers.add(nums[i]);
                        numbers.add(nums[j]);
                        numbers.add(nums[k]);
                        result.add(numbers);
                    }
                }
            }

        }
        return result;
    }


    public static void main(String[] args) {

        Problem13 problem13 = new Problem13();
        int[] array1 = {-1,0,1,2,-1,-4};
        List<List<Integer>> integers = problem13.threeSum(array1);
        Set<List<Integer>> setWithoutDuplicates = new HashSet<>(integers);
        System.out.println(setWithoutDuplicates);



    }


}
